<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/view/include/css-include.jsp"%>
<%@ include file="/view/include/jsp-include.jsp"%>
<%@ include file="/view/include/jquery-include.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript">

    $().ready(function() {
        view();

         /* 저장버튼 */
        $("#saveBtn").bind("click",function(){       
            $("form[name='shipperstockUpdateFrm']").submit();
        });

        $("#onList").bind("click",function(){
            location="/shipperstock.html";            
        });

        /* 메인폼 서브밋 */
        $("form[name='shipperstockUpdateFrm']").ajaxForm({
            dataType: "json",
            beforeSerialize: function($form, options) {
                //return $("form[name='orderFrm']").valid();  jquery 벨류데이션 플러그인 사용시
                 if( !validation() ){       //화면 항목 점검 시작
                    return false;
                }
            },
            success:function(data) {
               if(data.result == true){
                   alert("Saved.....!");
                   location="/shipperstock.html";    
               }               
           },
           error:function(){alert("ERROR!");}
        }); 
    });

    /* 조회 펑션 */
    function view(){
        $.post(
                '/getShipperstockDetailView.json', {
                custCode : $("#custCode").val(),
                goodsCode : $("#goodsCode").val()
                },
            function(data) {
                //reSetValidete(); //벨류데이션 초기화
                
                searchDataMaping(data);    //DATA맵핑 
            });
    }

    /* searchData 맵핑 */
    function searchDataMaping(data){
        var val = ""; 
        for(var v in data.resultDetailMap) {       //상단 조회 결과 맵핑 조회return값이 한건임
            $("#"+v).val(data.resultDetailMap[v]);
        }        
    }

    function validation(){
    	
        var iniQty     = $("#iniQty").val();
        if(iniQty==null || iniQty=="") {   alert("Initial Stock Qty required!!"); $("#iniQty").focus(); return false; }
   
      return true;      
    } 
    
</script>
</head>
<body>
<div class="wrap">
    <form name="shipperstockUpdateFrm" method="post" action="/saveShipperstock.json">
    <div class="pagetitle">
        <h1>Shipper Initial Stock / UPDATE</h1>
    </div>
    <div class="">
        <table class="TableST">
            <tr>
                <th>goods Name</th>
                <td><input type="text" class="inST" size="80" name="goodsName" id="goodsName" readonly=true/></td>
            </tr>
            <tr>
                <th>unit</th>
                <td><input type="text" class="inST" size="80" name="unit" id="unit" readonly=true/></td>
            </tr>
            <tr>
                <th>box Qty</th>
                <td><input type="text" class="inST" size="80" name="box Qty" id="box Qty" readonly=true/></td>
            </tr>
            <tr>
                <th>hsCode</th>
                <td>
                    <input type="text" class="inST" name="hsCode" id="hsCode" readonly=true/>
                </td>
            </tr>
            <tr>
                <th>shipperstockCode</th>
                <td><input type="text" class="inST" size="80" name="shipperstockCode" id="shipperstockCode" readonly=true/></td>
            </tr>
            <tr>
                <th>customer Name</th>
                <td><input type="text" class="inST" size="80" name="custName" id="custName" readonly=true/></td>
            </tr> 
            <tr>
                <th>Initial Stock Qty</th>
                <td>
                    <input type="text" class="inST" size="80" name="iniQty" id="iniQty" value="${iniQty}"/>
                </td>
            </tr>                      
         </table>
    </div>
    <div class="bo_btn">
        <a href="#"><img src="images/web/btn_confirm.png" alt="confirm" id="saveBtn"/></a>
        <a href="#"><img src="images/web/btn_cancel.png" alt="cancel" id="onList"/></a>
    </div>
    <input type="hidden" name="custCode" id="custCode" value="${custCode}"/>
    <input type="hidden" name="goodsCode" id="goodsCode" value="${goodsCode}"/>
    <input type="hidden" name="saveStatus" id="saveStatus" value="UPDATE"/>
    </form>
</div>
</body>
</html>